<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        h1{
            margin: 20px auto 20px ;
        }
       .fu{
           text-align: center;
       }
    </style>
</head>

<body>
    <div class="fu">
        <h1 id="txt">开始抽奖</h1>
    <button id="static">开始</button>
    <button id="end">结束</button>

    </div>
    <script>
        var txt=document.getElementById('txt')
        var static=document.getElementById('static')
        var end=document.getElementById('end')
        var user=['小明','小红','小蓝','小绿','小蓝'];
        var timer;
        static.onclick=function(){
            clearInterval(timer)
            timer=setInterval(function(){
                var o=parseInt(Math.random()*user.length)
                txt.innerHTML=user[o];
            },10)
        }
        end.onclick=function(){
            clearInterval(timer)
        }
    </script>
</body>
</html>